package com.dmpp.mes.service.impl;


import com.dmpp.mes.bean.ResponseData;
import com.dmpp.mes.dao.MaterialMapper;
import com.dmpp.mes.dao.ProductMapper;
import com.dmpp.mes.parameterInfo.Material;
import com.dmpp.mes.parameterInfo.Product;
import com.dmpp.mes.service.MaterialService;
import com.dmpp.mes.service.ProductService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service(value = "MaterialService")
public class MaterialServiceImpl implements MaterialService {


    @Autowired
    private MaterialMapper mapper;

    @Override
    public ResponseData findAll() {
        ResponseData responseData = new ResponseData();
        PageInfo pageInfo = new PageInfo<>(mapper.findAll());
        responseData.setData(pageInfo);
        return responseData;
    }

    @Override
    public ResponseData findByCode(String code) {
        ResponseData responseData = new ResponseData();
        responseData.setData(mapper.findByCode(code));
        return responseData;
    }


    @Override
    public ResponseData insert(Material material) {
        ResponseData responseData = new ResponseData();
        mapper.insert(material);
        return responseData;
    }

    @Override
    public ResponseData updateById(Material material) {
        ResponseData responseData = new ResponseData();
        mapper.updateById(material);
        return responseData;
    }


    @Override
    public ResponseData delete(String code) {
        ResponseData responseData = new ResponseData();
        mapper.delete(code);
        return responseData;
    }
}
